home *** CD-ROM | disk | FTP | other *** search
- on DBMain
- global gCurrentRecipe, gDBBeauty
- cursor(4)
- dbBeginSession()
- DBGetRecord(gCurrentRecipe, "beauty")
- set beauty to DBGetField(gDBBeauty)
- DBEndSession()
- cursor(-1)
- return beauty
- end
-
- on DBPlanner aRecipe
- global gRecipeIDDB, gDBCalories, gDBFat, gPlannerCalories, gPlannerFat
- cursor(4)
- set recipeID to getProp(gRecipeIDDB, aRecipe)
- DBGetRecord(recipeID, "recipe")
- set gPlannerCalories to integer(DBGetField(gDBCalories))
- set gPlannerFat to integer(DBGetField(gDBFat))
- cursor(-1)
- end
-
- on DBShopping recipeID
- global gDBResult, gDBQuantity, gDBUnit, gDBNoQuantity
- cursor(4)
- dbBeginSession()
- set shoppingQuantity to EMPTY
- set shoppingUnit to EMPTY
- set shoppingRest to EMPTY
- set ingredients to EMPTY
- DBGetRecord(recipeID, "ingredient")
- set quantity to DBGetField(gDBQuantity)
- set noQuantity to DBGetField(gDBNoQuantity)
- set shoppingQuantity to quantity & RETURN & RETURN
- set shoppingUnit to DBGetField(gDBUnit) & RETURN & RETURN
- set shoppingRest to noQuantity & RETURN & RETURN
- if quantity = 0 then
- set ingredients to noQuantity & RETURN & RETURN
- else
- set ingredients to floatToFrac(quantity) && noQuantity & RETURN & RETURN
- end if
- repeat while 1
- DBNextRecord("ingredient")
- if gDBResult = 2 then
- exit repeat
- end if
- set quantity to DBGetField(gDBQuantity)
- set noQuantity to DBGetField(gDBNoQuantity)
- put quantity & RETURN & RETURN after shoppingQuantity
- put DBGetField(gDBUnit) & RETURN & RETURN after shoppingUnit
- put noQuantity & RETURN & RETURN after shoppingRest
- if quantity = 0 then
- put noQuantity & RETURN & RETURN after ingredients
- next repeat
- end if
- put floatToFrac(quantity) && noQuantity & RETURN & RETURN after ingredients
- end repeat
- add(gAllQuantities, shoppingQuantity)
- add(gAllUnits, shoppingUnit)
- add(gAllRests, shoppingRest)
- DBEndSession()
- cursor(-1)
- return ingredients
- end
-
- on DBCollate
- global gDBResult, gDBCollate, gShoppingTitles, gCollateLists
- cursor(4)
- dbBeginSession()
- set gCollateLists to []
- repeat with aRecipe in gShoppingTitles
- set collateLines to EMPTY
- set recipeID to getProp(gRecipeIDDB, aRecipe)
- DBGetRecord(recipeID, "ingredient")
- set collateLines to DBGetField(gDBCollate) & RETURN & RETURN
- repeat while 1
- DBNextRecord("ingredient")
- if gDBResult = 2 then
- exit repeat
- end if
- put DBGetField(gDBCollate) & RETURN & RETURN after collateLines
- end repeat
- put RETURN after collateLines
- add(gCollateLists, collateLines)
- end repeat
- DBEndSession()
- cursor(-1)
- return(collateList)
- end
-
- on DBTermDefinition termID
- global gDBTermDefinition, gTermPhotoList
- cursor(4)
- dbBeginSession()
- DBGetRecord(termID, "terms")
- put DBGetField(gDBTermDefinition) into field "term text"
- set gTermPhotoList to DBTermPhotos(termID)
- DBEndSession()
- cursor(-1)
- end
-
- on DBTermPhotos termID
- global gDBResult, gDBTermPhotoFile
- cursor(4)
- dbBeginSession()
- set photo to 0
- set photoList to [:]
- repeat while 1
- set photo to integer(photo) + 1
- if photo < 10 then
- put "0" before photo
- end if
- set id to integer(termID & photo)
- DBGetRecord(id, "term photo")
- if gDBResult = 0 then
- addProp(photoList, id, DBGetField(gDBTermPhotoFile))
- next repeat
- end if
- exit repeat
- end repeat
- DBEndSession()
- cursor(-1)
- return photoList
- end
-
- on DBPhotoName photoID
- global gDBPhotoTitle
- cursor(4)
- dbBeginSession()
- DBGetRecord(photoID, "term photo")
- put DBGetField(gDBPhotoTitle) into field "photo title"
- DBEndSession()
- cursor(-1)
- end
-
- on DBPhotoCaption photoID
- global gDBPhotoCaption
- cursor(4)
- dbBeginSession()
- DBGetRecord(photoID, "term photo")
- set caption to DBGetField(gDBPhotoCaption)
- if caption = "|" then
- set caption to " "
- end if
- put caption into field "caption"
- DBEndSession()
- cursor(-1)
- end
-
- on DBTermLinks
- global gCurrentRecipe, gLastTermRecipe, gDBTermLinks, gTermIDDB, gRecipeIDDB
- cursor(4)
- DBBeginSearchSession()
- if gCurrentRecipe = gLastTermRecipe then
- exit
- end if
- set gLastTermRecipe to gCurrentRecipe
- set termList to []
- set results to DBStartSearch(gCurrentRecipe, gDBTermLinks)
- repeat with i = 1 to results
- set term to getOne(gTermIDDB, DBGetResult(i))
- if term <> 0 then
- add(termList, term & RETURN)
- end if
- end repeat
- sort(termList)
- if gCurrentRecipe > 2068 then
- put "No recipe specific terms available" into field "recipe terms"
- else
- put "Recipe: " & getOne(gRecipeIDDB, gCurrentRecipe) & RETURN & RETURN into field "recipe terms"
- end if
- put listToString(termList) after field "recipe terms"
- DBEndSession()
- cursor(-1)
- end
-
- on DBUtensil utensilID
- global gDBUtensilText
- cursor(4)
- dbBeginSession()
- DBGetRecord(utensilID, "utensil")
- put DBGetField(gDBUtensilText) into field "utensil text"
- DBEndSession()
- cursor(-1)
- end
-
- on DBFoodNutrition foodID
- global gDBNutritionUnit, gDBNutritionList
- cursor(4)
- dbBeginSession()
- DBGetRecord(foodID, "nutrition")
- put DBGetField(gDBNutritionUnit) into field "unit"
- set num to 0
- repeat with i in gDBNutritionList
- set num to num + 1
- put DBGetField(i) into field ("nutrition" & num)
- end repeat
- DBEndSession()
- cursor(-1)
- end
-
- on DBTableRows
- global gDBResult, gDBTableText, gCurrentTableID
- cursor(4)
- dbBeginSession()
- set id to char 1 to 2 of string(gCurrentTableID)
- set textID to integer(id & "0002")
- set rowID to integer(id & "0003")
- set noteID to integer(id & "0004")
- DBGetRecord(textID, "tables")
- if gDBResult = 0 then
- set tableText to DBGetField(gDBTableText) & RETURN
- else
- set tableText to "No Additional Information"
- end if
- if noteID <> 320004 then
- DBGetRecord(noteID, "tables")
- if gDBResult = 0 then
- put RETURN & RETURN & DBGetField(gDBTableText) after tableText
- end if
- end if
- put tableText into field "table text"
- put tableText into field "table text scroll"
- DBGetRecord(rowID, "tables")
- put DBGetField(gDBTableText) into field "row name"
- set rows to EMPTY
- set rowsNum to 0
- repeat while 1
- set rowsNum to integer(rowsNum + 1)
- if rowsNum < 10 then
- put "0" before rowsNum
- end if
- set rowsID to integer(id & rowsNum & "01")
- DBGetRecord(rowsID, "tables")
- if gDBResult = 2 then
- exit repeat
- end if
- put DBGetField(gDBTableText) & RETURN & RETURN after rows
- end repeat
- put rows into field "rows"
- DBEndSession()
- cursor(-1)
- end
-
- on DBRowItems
- global gDBResult, gDBTableText, gLastRowLine, gCurrentTableID
- cursor(4)
- dbBeginSession()
- set id to char 1 to 2 of string(gCurrentTableID)
- set midID to (gLastRowLine / 2) + 1
- if midID < 10 then
- put "0" before midID
- end if
- set itemsID to integer(id & midID & "02")
- DBGetRecord(itemsID, "tables")
- put DBGetField(gDBTableText) into field "row items"
- DBEndSession()
- cursor(-1)
- end
-
- on DBChooser
- global gDBStartSearch, gDBSearchMenu, gDBSearchMenus, gDBMenuTypes, gDBMenuIDs, gDBSearchIngredient, gDBSearchIngredients, gStandardIDDB, gLastResults
- cursor(4)
- set results to gLastResults
- set addedMenu to 0
- set addedIngredient to 0
- set oldMenuNum to count(gDBSearchMenus)
- repeat with id in gDBMenuIDs
- set menuP to getPos(gDBSearchMenus, id)
- set searchString to getAt(gDBMenuTypes, id)
- set fieldName to getOne(gDBMenuTypes, searchString)
- if not menuP and (field fieldName = searchString) then
- set addedMenu to id
- add(gDBSearchMenus, id)
- next repeat
- end if
- if menuP and (field fieldName <> searchString) then
- deleteAt(gDBSearchMenus, menuP)
- set gDBStartSearch to 1
- end if
- end repeat
- set newMenuNum to count(gDBSearchMenus)
- set oldIngredientNum to count(gDBSearchIngredients)
- set ingredientIDs to []
- if field "ingredients selected" <> "No Ingredients Selected" then
- set ingredients to stringToList(field "ingredients selected")
- repeat with i in ingredients
- if i <> EMPTY then
- set id to getProp(gStandardIDDB, i)
- add(ingredientIDs, id)
- set ingredientP to getPos(gDBSearchIngredients, id)
- if not ingredientP then
- set addedIngredient to id
- add(gDBSearchIngredients, id)
- end if
- end if
- end repeat
- end if
- set gDBSearchIngredients to ingredientIDs
- set newIngredientNum to count(gDBSearchIngredients)
- if newIngredientNum < oldIngredientNum then
- set gDBStartSearch to 1
- end if
- if gDBStartSearch and (gDBSearchMenus <> []) and (gDBSearchIngredients <> []) then
- set gDBStartSearch to 0
- set id to getAt(gDBSearchMenus, 1)
- set results to DBStartSearch(id, gDBSearchMenu)
- repeat with i = 2 to newMenuNum
- set id to getAt(gDBSearchMenus, i)
- put id
- put id
- set results to DBAddSearch(id, gDBSearchMenu)
- put "results are ", results
- end repeat
- repeat with i = 1 to newIngredientNum
- set id to getAt(gDBSearchIngredients, i)
- set results to DBAddSearch(id, gDBSearchIngredient)
- end repeat
- else
- if gDBStartSearch and (gDBSearchMenus <> []) then
- set gDBStartSearch to 0
- set id to getAt(gDBSearchMenus, 1)
- put id
- set results to DBStartSearch(id, gDBSearchMenu)
- repeat with i = 2 to newMenuNum
- set id to getAt(gDBSearchMenus, i)
- set results to DBAddSearch(id, gDBSearchMenu)
- end repeat
- else
- if gDBStartSearch and (gDBSearchIngredients <> []) then
- set gDBStartSearch to 0
- set id to getAt(gDBSearchIngredients, 1)
- put id
- set results to DBStartSearch(id, gDBSearchIngredient)
- repeat with i = 2 to newIngredientNum
- set id to getAt(gDBSearchIngredients, i)
- set results to DBAddSearch(id, gDBSearchIngredient)
- end repeat
- else
- if addedMenu then
- set results to DBAddSearch(addedMenu, gDBSearchMenu)
- else
- if addedIngredient then
- set results to DBAddSearch(addedIngredient, gDBSearchIngredient)
- else
- if (gDBSearchMenus = []) and (gDBSearchIngredients = []) then
- set results to 0
- set gDBStartSearch to 1
- end if
- end if
- end if
- end if
- end if
- end if
- set gDBStartSearch to 1
- if results > 0 then
- set gLastResult to results
- else
- set gLastResult to 0
- end if
- setShowRecipes(results)
- cursor(-1)
- end
-
- on DBVideoLinks
- global gCurrentRecipe, gLastVideoRecipe, gDBVideoLinks, gVideoIDDB, gRecipeIDDB
- if gCurrentRecipe = gLastVideoRecipe then
- exit
- end if
- cursor(4)
- DBBeginSearchSession()
- set gLastVideoRecipe to gCurrentRecipe
- set videoList to []
- set results to DBStartSearch(gCurrentRecipe, gDBVideoLinks)
- repeat with i = 1 to results
- set videoTitle to getOne(gVideoIDDB, DBGetResult(i))
- if (videoTitle <> 0) and (videoTitle <> "Cut Poultry Into Bite-Sized Strips ") then
- add(videoList, videoTitle & RETURN)
- end if
- end repeat
- sort(videoList)
- if gCurrentRecipe > 2068 then
- put "No recipe specific videos available" into field "recipe videos"
- else
- if gCurrentRecipe < 1701 then
- put "No recipe specific videos available" into field "recipe videos"
- else
- if videoList = [] then
- put "No recipe specific videos available" into field "recipe videos"
- else
- put "Recipe: " & getOne(gRecipeIDDB, gCurrentRecipe) & RETURN & RETURN into field "recipe videos"
- put listToString(videoList) after field "recipe videos"
- end if
- end if
- end if
- DBEndSession()
- cursor(-1)
- end
-
- on DBBookToPersonal
- global gCurrentRecipe, gDBResult, gDBTitle, gDBServings, gDBPrepTime, gDBDishType, gDBIngredient, gCurrentPrepTime, gCurrentDishType, gDBInstruction, gDBInstructionType
- cursor(4)
- dbBeginSession()
- DBGetRecord(gCurrentRecipe, "recipe")
- put integer(DBGetField(gDBServings)) into field "servings"
- DBGetRecord(gCurrentRecipe, "prep time")
- set gCurrentPrepTime to integer(DBGetField(gDBPrepTime))
- DBGetRecord(gCurrentRecipe, "dish type")
- set gCurrentDishType to DBGetField(gDBDishType)
- set ingredients to EMPTY
- DBGetRecord(gCurrentRecipe, "ingredient")
- set ingredient to DBGetField(gDBIngredient)
- set ingredients to ingredient & RETURN & RETURN
- repeat while 1
- DBNextRecord("ingredient")
- if gDBResult = 2 then
- exit repeat
- end if
- set ingredient to DBGetField(gDBIngredient)
- put ingredient & RETURN & RETURN after ingredients
- end repeat
- put ingredients into field "ingredients"
- put ingredients into field "ingredients scroll"
- set instructions to EMPTY
- set num to 1
- DBGetRecord(gCurrentRecipe, "instruction")
- if DBGetField(gDBInstructionType) = 1.0 then
- set anInstruction to DBGetField(gDBInstruction)
- set instructions to num & ". " & anInstruction & RETURN & RETURN
- end if
- repeat while 1
- set num to num + 1
- DBNextRecord("instruction")
- if gDBResult = 2 then
- exit repeat
- end if
- if DBGetField(gDBInstructionType) = 1.0 then
- set anInstruction to DBGetField(gDBInstruction)
- put num & ". " & anInstruction & RETURN & RETURN after instructions
- next repeat
- end if
- exit repeat
- end repeat
- put RETURN after instructions
- put instructions into field "instructions"
- put instructions into field "instructions scroll"
- DBEndSession()
- cursor(-1)
- end
-
- on removeMethodTag anInstruction
- end
-
- on DBEditPersonal
- global gDBResult, gCurrentPrepTime, gCurrentDishType, gCurrentRecipe
- if gCurrentRecipe < 2068 then
- exit
- end if
- cursor(4)
- DBBeginSaveSession()
- DBGetSetRecord(gCurrentRecipe, "personal recipe")
- put integer(DBGetSetField(3003)) into field "servings"
- set gCurrentPrepTime to integer(DBGetSetField(3006)) + 1000
- set gCurrentDishType to integer(DBGetSetField(3005))
- set instructions to DBGetSetField(20001)
- put instructions into field "instructions"
- put instructions into field "instructions scroll"
- set ingredients to EMPTY
- DBGetSetRecord(gCurrentRecipe, 4000)
- if gDBResult = 0 then
- set ingredient to DBGetSetField(4004)
- set ingredients to ingredient & RETURN & RETURN
- repeat while 1
- DBNextSetRecord(4000)
- if gDBResult <> 0 then
- exit repeat
- end if
- if integer(DBGetSetField(4000)) <> gCurrentRecipe then
- exit repeat
- end if
- set ingredient to DBGetSetField(4004)
- put ingredient & RETURN & RETURN after ingredients
- end repeat
- put ingredients into field "ingredients"
- put ingredients into field "ingredients scroll"
- end if
- DBEndSession()
- cursor(-1)
- end
-